package joke.deal;

import joke.ibatis.dao.ContentDao;
import joke.ibatis.dao.WeightDao;
import joke.ibatis.po.ContentPo;
import joke.ibatis.po.ParameterPo;
import joke.ibatis.po.WeightPo;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ReJoke {
	public ContentPo viewContent() {
		ApplicationContext factory = new ClassPathXmlApplicationContext(
				"applicationContext.xml");// 初始化配置文件
		ContentDao cdao = (ContentDao) factory.getBean("contentDao");// 获取pageLinkDao对象
		ContentPo po = cdao.getContentById("1");
		WeightDao wdao = (WeightDao) factory.getBean("weightDao");// 获取pageLinkDao对象
		WeightPo wpo = wdao.getWeightPo("joke");
		po.setWpo(wpo);
		return po;

	}

	public void recordSms(String id) {
		ApplicationContext factory = new ClassPathXmlApplicationContext(
				"applicationContext.xml");// 初始化配置文件
		ContentDao cdao = (ContentDao) factory.getBean("contentDao");// 获取pageLinkDao对象
		cdao.updateJoke(id);
	}

	public ContentPo viewContentByOrder(ParameterPo parpo) {
		ApplicationContext factory = new ClassPathXmlApplicationContext(
				"applicationContext.xml");// 初始化配置文件
		ContentDao cdao = (ContentDao) factory.getBean("contentDao");// 获取pageLinkDao对象
		ContentPo po = cdao.getContentOrder(parpo);
		return po;
	}
}
